<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var step2 = 100;
        var step3 = 40;
        var step4 = 40;
        window.onload = function (){
            setInterval(move,100);
        }
        function move(){
            var divElement = document.getElementById("div_img");
            var left = parseInt(divElement.style.left);
            var top = parseInt(divElement.style.top);

            if(left > 1300 || left < 100){
                step3 = -step3;
            }
            if(top > 600 || top < 100){
                step4 = -step4;
            }
            left = (left + step3 )+ "px";
            top = (top + step4 )+ "px";
            divElement.style.left = left;
            divElement.style.top = top;
        }
        function bbb(){
            var imgElement = document.getElementById("img");
            var width = parseInt(imgElement.style.width);
            var height = parseInt(imgElement.style.height);
            if(width > 300 || width < 200){
                step2 = -step2;
            }
            imgElement.style.width = (width + step2 ) + "px";
            imgElement.style.height = (height + step2 ) + "px";
        }
    </script>
</head>
<body>
<input type="button" value="变变变" onclick="bbb()">
    <div id="div_img" style="position: absolute;left: 100px;top: 100px;">
        <img src="../img/demo3/1.jpg" style="width: 200px ; height: 200px" id="img" >
    </div>
</body>
</html>